from rest_framework import serializers
from rest_framework.serializers import ModelSerializer

from goods.models import GoodsChannel, GoodsChannelGroup


class GoodsChannelGroupSerializer(ModelSerializer):
    class Meta:
        model = GoodsChannelGroup
        fields = '__all__'

class GoodsChannelSerializer(ModelSerializer):
    #关联嵌套
    group = serializers.StringRelatedField(read_only=True)
    category = serializers.StringRelatedField(read_only=True)
    group_id = serializers.IntegerField()
    category_id = serializers.IntegerField()
    class Meta:
        model = GoodsChannel
        fields = '__all__'
